

class StudentManager():
    def __init__(self):
        self.students = []

    def start(self):
        while True:
            self.show_info()
            a = int(input("请输入序号: "))
            if a == 1:
                self.add_student()
            elif a == 2:
                self.del_student()
            elif a == 3:
                self.select_student()
            elif a == 4:
                self.update_student()


    def show_info(self):
        """展示信息"""
        print("添加学生输入1")
        print("删除学生输入2")
        print("查看学生输入3")
        print("修改学生输入4")

    def add_student(self):
        """添加学生"""
        name = input("请输入名字: ")
        gender = input("请输入性别: ")
        age = int(input("请输入年龄: "))
        self.students.append({"name": name, "gender": gender, "age": age})
        print("添加成功")

    def del_student(self):
        name1 = input("请输入要删除名字: ")
        for i in self.students:
            if name1 == i.get('name'):
                self.students.remove(i)
                print("删除成功")
                break
        else:
            print('该学生不存在')

    def select_student(self):
        """查看学生"""
        name2 = input("请输入要查看名字: ")
        for i in self.students:
            if name2 == i.get('name'):
                print(i)
                break
        else:
            print('该学生不存在')

    def update_student(self):
        """修改学生"""
        name3 = input("请输入要修改名字: ")
        for i in self.students:
            if name3 == i.get('name'):
                name1 = input("请输入名字: ")
                gender1 = input("请输入性别: ")
                age1 = int(input("请输入年龄: "))
                i.update({
                    "name": name1,
                    "gender": gender1,
                    "age": age1
                })
                break
        else:
            print('该学生不存在')

student_manger = StudentManager()
student_manger.start()